home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / VISUALBA / VBTBOX.ZIP / PARENT.FRM < prev    next >
Text File  |  1993-09-10  |  2KB  |  67 lines

  1. VERSION 2.00
  2. Begin Form Parent 
  3.    Caption         =   "Parent"
  4.    ClientHeight    =   1965
  5.    ClientLeft      =   1305
  6.    ClientTop       =   1740
  7.    ClientWidth     =   4095
  8.    Height          =   2655
  9.    Left            =   1245
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   1965
  12.    ScaleWidth      =   4095
  13.    Top             =   1110
  14.    Width           =   4215
  15.    WindowState     =   2  'Maximized
  16.    Begin Menu Showtbox 
  17.       Caption         =   "&Show Toolbox"
  18.    End
  19.    Begin Menu Exit 
  20.       Caption         =   "&Exit"
  21.    End
  22. End
  23. Option Explicit
  24. 'This is a simple demo of how to do a
  25. 'floating toolbox in VB as requested
  26. 'by a few people on the VISBAS-L
  27. 'mailing list.
  28.  
  29. 'Hope this is of use to someone
  30. 'Matthew Dexter (ch01md@surrey.ac.uk)
  31.  
  32. 'Declare SetParent API function
  33. Declare Function SetParent% Lib "User" (ByVal hWndChild%, ByVal hWndNewParent%)
  34. Dim doshow As Integer 'Boolean to decide if toolbox is hidden or shown
  35.  
  36. Sub Exit_Click ()
  37. 'quit program
  38. Unload Me
  39. End Sub
  40.  
  41. Sub Form_Load ()
  42. doshow = False  'initially toolbox is not shown
  43. Load tbox 'toolbox is loaded but not yet shown
  44. End Sub
  45.  
  46. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  47. Unload tbox 'essential or else VB will crash!!!
  48. End Sub
  49.  
  50. Sub ShowTbox_Click ()
  51. Dim ret As Integer
  52. If doshow = False Then 'toolbox not visible
  53.     ret = SetParent(tbox.hWnd, parent.hWnd) 'this makes the toolbox float
  54.     tbox.Left = 0 'sets position to top left corner of parent
  55.     tbox.Top = 0
  56.     tbox.Show 'makes toolbox visible
  57. 'try tbox.show 1 i.e. modal to see what happens
  58.     doshow = True
  59.     Showtbox.Caption = "&Hide Toolbox"
  60. Else
  61.     tbox.Hide
  62.     doshow = False
  63.     Showtbox.Caption = "&Show Toolbox"
  64. End If
  65. End Sub
  66.  
  67.